#!/usr/bin/python3.8
# -*- coding: utf-8 -*-
# @Time    : 2021/3/6 5:25 下午 
# @Author  : zhaohexin
# @Email   : 1483643520@xxx.com
# @File    : model.py
# @Software: PyCharm 
# @FileDescription： 岗位模型类创建

from DatabaseOperation.BaseModel import BaseModel
from sqlalchemy import Column, VARCHAR, Integer, Boolean


class Jobs(BaseModel):
    """
    岗位表
    """
    __tablename__ = "sys_job"
    __table_args__ = ({"comment": "岗位表"})

    name = Column(VARCHAR(255), nullable=False, comment="岗位名称")
    enabled = Column(Boolean, nullable=False, comment="是否启用")
    sort = Column(Integer, nullable=True, default=0, comment="排序")

    # 把SQLAlchemy查询对象转换成字典
    def to_dict(self):
        return {
            "id": self.id,
            "jobSort": self.sort,
            "name": self.name,
            "enabled": self.enabled,
            "createTime": self.create_time.strftime('%Y-%m-%d %H:%M:%S'),
            "updateTime": self.update_time.strftime('%Y-%m-%d %H:%M:%S')
        }